<div class="widget" id="categories_div">
        <div class="head"><h5 class="iList">Matching categories with empty content</h5></div>
            <fieldset>
            
		     	<div class="rowElem noborder" id="checkboxes_div" >
		     		<div class="formLeft" >
						<?php
						$break_counter = 1;
						
						foreach ($matching_categories as $matching_category){
							?>
							<div style="float:left; width:260px; padding-bottom: 5px"> 
							<input type="checkbox" name="empty_category[]" value="<?php echo $matching_category->getId()?>">
								<?php echo $matching_category->getName() . ' (' . $matching_category->getMasterDirectory() .')' ?> 
							</div>
							<?php
							if ($break_counter % 3 == 0){
							?>
							<div class="fix"></div>
							<?php 
							} 
							$break_counter++;
						}
						
						?>
						<div class="fix"></div>
  		
		     		</div>
		     		 
		     		 
		     		<div class="fix"></div>
		     		
		     		
		     	</div>            
 
            </fieldset>
</div>

<div id="error_msg" class="error_msg" style="clear:both; display: none; cursor:pointer;" onclick="$(this).hide('slow')">
		<div id="msg_text" ></div>
</div>
	
		<?php if (count($matching_categories) > 0){?>
		<div style="margin-top:20px; float: right; margin-right: -13px;" id="btn_div">
			<input type="submit" value="Copy contents!!!" id="copy_contents" class="greyishBtn submitForm">
		</div>	
		<div id="copying" style="display:none;float: right; margin-top:20px;">
			<div style="float:left;"><?php echo image_tag("loaders/loader.gif", array('class'=>'p12')) ?></div>	
			<div style="float:left;margin-top: 8px;"><b>Copying...</b></div>
		</div>
		<?php } else { ?>
		<script>
		$("#checkboxes_div").html("<i>There are no empty categories with a similar structure to the selected category</i>");
		</script>
		
		<?php }?>   


<script>



$("#copy_contents").click(function (event){
	event.preventDefault();
	if ($('input:checked', $('form#copy_contents_form')).length == 0){
		$("#error_msg").show();
		$("#msg_text").html("Please, select at least one matching category");
		return false;
	}
	else{
		var from_content =  $('#sl_categories option:selected').text() ;
		jConfirm('Are you sure you want to copy the contents of ' + from_content + ' to the selected categories?', 'Confirmation Dialog', function(r){if (!r){return false} else {$("#btn_div").hide(); $("#copying").show(); $('form#copy_contents_form').submit()}});
		
	}

})
</script>